package com.example.munyandroid;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class AlltableAdapter extends BaseAdapter 
{

	private Context         context = null;
	private ArrayList<Alltable> data = null;
	private int             resource = 0;
	
	public AlltableAdapter(Context context,
			ArrayList<Alltable> data,
			int resource)
	{
		this.context = context;
		this.data = data;
		this.resource = resource;
	}
	
	@Override
	public int getCount() 
	{
		return data.size();
	}

	@Override
	public Object getItem(int position) 
	{
		return data.get(position);
	}

	@Override
	public long getItemId(int position) 
	{
		Alltable alltable = data.get(position);
		long id = alltable.getId();
		return id;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		Alltable alltable = data.get(position);
		
		View view = convertView;
		if(view == null)
		{
			LayoutInflater inflater
			= LayoutInflater.from(context);
			view = inflater.inflate
					(resource,
					parent,
					false);
		}
		TextView textView =
				(TextView)view.findViewById(R.id.tablenum);
		textView.setText(alltable.getTablename());
		
		textView =
				(TextView)view.findViewById(R.id.tablenow);
		textView.setText(alltable.getTablenow());
		return view;
	}
}
